package com.rsk.dao.extend;


import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 数据字典查询数据字段
 */

@Component
public class SysParamsConfigExtend {

    public Map<String,Object> selectParamsConfig(String paramName, String paramCode){

        //拼接SQL语句
        StringBuilder builder = new StringBuilder("select param_name,param_code from sys_params_config");

        //查询需要的参数，先存进Map
        StringBuilder stringBuilder = new StringBuilder();
        HashMap<Object, Object> hashMap = new HashMap<>();

        if(paramName != null && !paramName.isEmpty() ){

            stringBuilder.append("and param_name like :paramName");
            hashMap.put("param_name","%"+ paramName+"%");
        }

        if(paramCode != null && !paramCode.isEmpty() ){

            stringBuilder.append("and param_code like :paramCode");
            hashMap.put("param_code","%"+ paramCode+"%");
        }

        //排序
        StringBuilder orderSql = new StringBuilder();
        orderSql = orderSql.append(" order by sort");

        Map<String, Object> returnMap = new HashMap<String, Object>();
        returnMap.put("sql", builder.append(stringBuilder).append(orderSql));
        returnMap.put("hashMap", hashMap);
        return returnMap;

    }
}

